﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KP_CommonLibrary.KP_CommonControls.NumericInput
{
    public class MaskManagerCommonState : MaskManagerState
{
    // Fields
    private int cursorPosition;
    private string editText;
    public static MaskManagerCommonState Empty = new MaskManagerCommonState(string.Empty, 0, 0);
    private int selectionAnchor;

    // Methods
    public MaskManagerCommonState(string editText, int cursorPosition, int selectionAnchor)
    {
        this.editText = editText;
        this.cursorPosition = cursorPosition;
        this.selectionAnchor = selectionAnchor;
    }

    public override bool IsSame(MaskManagerState comparedState)
    {
        if (comparedState == null)
        {
            return false;
        }
        if (base.GetType() != comparedState.GetType())
        {
            throw new NotImplementedException("Internal error");
        }
        MaskManagerCommonState state = (MaskManagerCommonState) comparedState;
        if (this.EditText != state.EditText)
        {
            return false;
        }
        if (this.CursorPosition != state.CursorPosition)
        {
            return false;
        }
        if (this.SelectionAnchor != state.SelectionAnchor)
        {
            return false;
        }
        return true;
    }

    // Properties
    public int CursorPosition
    {
        get
        {
            return this.cursorPosition;
        }
    }

    public string EditText
    {
        get
        {
            return this.editText;
        }
    }

    public int SelectionAnchor
    {
        get
        {
            return this.selectionAnchor;
        }
    }
}

 

 

}
